clear all
set more off
cap log close

** plaatjes=1 if graphs need to be generated, 0 otherwise.
local plaatjes=0

********************************************************************************
***** Project: The Short and Long Term Effects of In-Person Performance Feedback
********************************************************************************
***** A. R. Soetevent & G. J. Romensen
********************************************************************************
***** Regressions Peer Comparisons
********************************************************************************
global filepath "C:\JPEMicReplication"
global paperpath "$filepath\TablesGraphs"
local abcd "acceleratie rem bochten fueleconomyLpKM"
log using "$filepath/Logs/X03RegrPeerComp.log", replace



/*** Notes ***/
*=> No   economy observations postfeedback in urban area.
*=> Fuel Economy: kilometers per liter of fuel
*=> ABC dimensions: number of events per 10 kilometers
/*************/

use "$filepath\DEPO\DataMainAnalysisDEPO.dta"

* Input Figure G5 (created in: TablesPaper - Nov22.xlsx)
statsmat dep_fueleconomyLpKM if regio=="FR", by(weekindex) stat(mean se)  f(%9.5g)
statsmat dep_fueleconomyLpKM if regio=="ZH", by(weekindex) stat(mean se)  f(%9.5g)


** Define regional dummies: ZH and FR** 
gen byte ZH = 0 
replace ZH = 1 if regio == "ZH"
gen byte FR = 0 
replace FR = 1 if regio == "FR"

replace intouro = 0 if intouro ==.

****************************************
*** A. Create week-year dummies
****************************************

gen int weekT1=0
gen int weekT2=0
gen int weekT3=0
gen int weekT4=0

replace weekT1=weekindex if treatment=="T1"
replace weekT2=weekindex if treatment=="T2"
replace weekT3=weekindex if treatment=="T3"
replace weekT4=weekindex if treatment=="T4"

gen int weekT=0

/*** Determine the set of observations used for the analysis ***/
gen byte regobsfuel=1
replace regobsfuel=0 if geplande_ritafstand==. | lnovcheckins==. | punctuality==. | aantal_haltes==. | dep_fueleconomyLpKM==.

gen byte regobsabc=1
replace regobsabc=0  if geplande_ritafstand==. | lnovcheckins==. | punctuality==. | aantal_haltes==. | dep_acceleratie==. | dep_bochten==. | dep_rem==.


****************************************
*** B. Create global list of covariates
****************************************

global covBusType "vdl10 vdl14 iris10 iris10cng iris12 iris12cng intouro vvo89 vvo77H daf"
* (vdl12 = default - more than 50 per cent of observations)

global covWeatherExt "Temp6_3C Temp3_0C Temp0_3C Temp3_6C Temp9_12C Temp12_15C Temp15_18C Temp18_21C Temp21_24C Temp24_27C Rain5_10mm Rain10_15mm Rain15_20mm Rain20_30mm Rain30_40mm Wind0_2ms Wind4_6ms Wind6_8ms Wind8_10ms Wind10_20ms"  
*(Defaults: Wind2_4ms, Temp6_9C, Rain0_5mm)
global covWeather "Temp10_5C Temp5_10C Temp15_20C Temp20_25C Rain0_5mm Rain5_50mm Wind0_3ms Wind5_8ms Wind8_20ms"  
*(Defaults: Wind4_5ms, Temp10_15C, Rain0_0mm)

global covEnvironm "ochtendspits avondspits uitleenrit geplande_ritafstand aantal_haltes stadsrit"

global covPassengers "lnovcheckins ovcheckinsmissing"

global covRegion "FR"

** Postcoaching dummies: non treatment-specific
global  covPostCoaching
	foreach x of numlist 0(7)70 {
		global covPostCoaching "$covPostCoaching daysaftercoachingA`x'" 
	}
	global covPostCoaching "$covPostCoaching daysaftercoachingA70plus"

** Postcoaching dummies: treatment-specific
global  covPostCoachingT
foreach i of numlist 1(1)4 {
	foreach x of numlist 0(7)70 {
		global covPostCoachingT "$covPostCoachingT daysaftercoaching`x'T`i'" 
	}
	global covPostCoachingT "$covPostCoachingT daysaftercoaching70T`i'plus"
}

global weekidx 
global weekidxT1
forv i = 1/108 {
global weekidx "$weekidx `i'.weekindex"
global weekidxT "$weekidxT `i'.weekT"
}

set matsize 10000
gen byte selectie=0
xtset chauf_nr_rug 

*-------------------------------------------------------------------------------------
*** Drop all Irisbus observations
*** This part -- trends over time -- is based on VDL and INTOURO buses
drop if bustype==3

*************************************
** Estimation treatment effects + plots
*************************************

** Effects per feedback round
foreach x of numlist 2(1)4 {
	foreach y of numlist 0(1)12 {
		bysort chauf_nr_rug: gen T`x'xfeedround_`y'=T`x'*feedround_`y'*postfeedback
	}
}
foreach x of numlist 2(1)4 {
	foreach y of numlist 1(1)2 {
		bysort chauf_nr_rug: gen T`x'xfeedround_min`y'=T`x'*feedround_min`y'
	}
}

xtset chauf_nr_rug 


************************************************************************
*** TABLES 7 + G10 -- Targeted Peer-Comparison Feedback Effects
************************************************************************

local abcd "acceleratie rem bochten fueleconomyLpKM"
local k = 0 

** REGRESSIONS ** 
foreach var of local abcd {
		local k = `k' + 1
		if `k'<4 {
		replace selectie=regobsabc 
		}
		if `k' == 4 {
		replace selectie=regobsfuel 
		}
di "`var'"


****************************************************************************
*** [Table 7 -- Targeted Peer-Comparison Feedback Effects on Fuel Economy]
****************************************************************************
if `k' == 4 {
* PERIOD TILL 30-04-2016:
* (0) RE	
reg dep_`var' postfeedback  $covRegion noreport nonotification if selectie==1 & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"),  vce(cl chauf_nr_rug)
** Note 01.10.2021: Small diff with (*1) diff dep_fueleconomyLpKM if selectie==1 & datum>=date("01-07-2015", "DMY")  & datum <=date("31-10-2016", "DMY"),  t(treated) p(tijd2) cl(datum) is due to fact that latter ignores that not all drivers receive initial feedback at 15-12-2015 + slightly smaller # of obs. here because not all controls all available for all trips
estadd loc controls "No", replace
estadd loc driverfe "No", replace
estadd loc dayfe 	"No", replace	
estadd loc busdayfe "No", replace 
*estadd loc weer	    "No", replace
estimates store ms`var'0,  title(ms`var'0)
* (1) RE 
reg dep_`var' postfeedback postfeedbackxT* T2 T3 T4 noreport nonotification $covRegion if selectie==1 & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"),  vce(cl chauf_nr_rug)
estadd loc controls "No", replace
estadd loc driverfe "No", replace	
estadd loc dayfe 	"No", replace	
estadd loc busdayfe "No", replace 
estimates store ms`var'1,  title(ms`var'1)
* (2) RE 
areg dep_`var' postfeedback postfeedbackxT* T2 T3 T4 noreport nonotification $covWeather $covBusType $covPassengers $covEnvironm $covPostCoaching $covRegion if selectie==1  & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"), absorb(chauf_nr_rug)  vce(cl chauf_nr_rug)
estadd loc controls "Yes", replace
estadd loc driverfe "Yes" , replace
estadd loc dayfe 	"No" , replace	
estadd loc busdayfe "No" , replace 
estimates store ms`var'2,   title(ms`var'2)
* These estimates also show that a before-and-after comparison to examine the announcement effect of the monitoring program gives an estimate of -0.294, significant at p<0.001.

* (3) FE 
areg dep_`var' postfeedback postfeedbackxT* noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching $covRegion i.datum if selectie==1  & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"), absorb(chauf_nr_rug) vce(cl chauf_nr_rug)
estadd loc controls "Yes", replace
estadd loc driverfe "Yes", replace
estadd loc dayfe 	"Yes" , replace	
estadd loc busdayfe "No" , replace 
estimates store ms`var'3, title(ms`var'3)
* (4) FE + day and bustype fixed effects (including interactions)
areg dep_`var' postfeedback  postfeedbackxT* noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching $covRegion  i.datum i.bustype#i.datum if selectie==1 & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"), absorb(chauf_nr_rug) vce(cl chauf_nr_rug)
estadd loc controls "Yes", replace
estadd loc driverfe "Yes", replace
estadd loc dayfe 	"Yes", replace
estadd loc busdayfe "Yes", replace 
estimates store ms`var'4,  title(ms`var'4)


* Table 6E. Robustness check: aggregate effect postannouncement instead of postfeedback 
* PERIOD TILL 30-04-2016:
* (1) RE 
reg dep_`var' postannouncement postfeedbackxT* T2 T3 T4 noreport nonotification $covRegion if selectie==1 & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"),  vce(cl chauf_nr_rug)
estadd loc controls "No", replace
estadd loc driverfe "No", replace	
estadd loc dayfe 	"No", replace	
estadd loc busdayfe "No", replace 
estimates store mx`var'1,  title(mx`var'1)
* (2) RE 
areg dep_`var' postannouncement postfeedbackxT* T2 T3 T4 noreport nonotification $covWeather $covBusType $covPassengers $covEnvironm $covPostCoaching $covRegion if selectie==1  & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"), absorb(chauf_nr_rug)  vce(cl chauf_nr_rug)
estadd loc controls "Yes", replace
estadd loc driverfe "Yes" , replace
estadd loc dayfe 	"No" , replace	
estadd loc busdayfe "No" , replace 
estimates store mx`var'2,   title(mx`var'2)
* These estimates also show that a before-and-after comparison to examine the announcement effect of the monitoring program gives an estimate of -0.294, significant at p<0.001.

* (3) FE 
areg dep_`var' postannouncement postfeedbackxT* noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching $covRegion i.datum if selectie==1  & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"), absorb(chauf_nr_rug) vce(cl chauf_nr_rug)
estadd loc controls "Yes", replace
estadd loc driverfe "Yes", replace
estadd loc dayfe 	"Yes" , replace	
estadd loc busdayfe "No" , replace 
estimates store mx`var'3, title(mx`var'3)
* (4) FE + day and bustype fixed effects (including interactions)
areg dep_`var' postannouncement  postfeedbackxT* noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching $covRegion  i.datum i.bustype#i.datum if selectie==1 & datum>=date("01-07-2015", "DMY")  & datum <=date("30-04-2016", "DMY"), absorb(chauf_nr_rug) vce(cl chauf_nr_rug)
estadd loc controls "Yes", replace
estadd loc driverfe "Yes", replace
estadd loc dayfe 	"Yes", replace
estadd loc busdayfe "Yes", replace 
estimates store mx`var'4,  title(mx`var'4)

}


************************************************************************************
*** [Table G10 -- Targeted Peer-Comparison Feedback Effects on ABC Comfort Dimensions]
************************************************************************************
if `k'<4 {
* period till 30-04-2016
reg dep_`var' postfeedback postfeedbackxT* T2 T3 T4 noreport nonotification if selectie==1 & datum <=date("30-04-2016", "DMY") & ZH == 0,  vce(cl chauf_nr_rug)
estadd loc controls "No", replace
estadd loc driverfe "No", replace
estadd loc dayfe 	"No", replace	
estadd loc busdayfe "No", replace 
estimates store ms`var'1,  title(ms`var'1)

}


}

** TABLES IN TEX ** 
local verklvar "postfeedback postfeedbackxT* FR _cons"
local verklvartwo "postfeedbackxT* postfeedback _cons"
label variable postannouncement "Post-announcement"
label variable T2 "T2 (1n/0p)"
label variable T3 "T3 (1n/1p)"
label variable T4 "T4 (3n/0p)"
label variable postfeedback "Post-feedback" 
label variable postfeedbackxT2 "Post-feedback $\times$ T2 (1n/0p)" 
label variable postfeedbackxT3 "Post-feedback $\times$ T3 (1n/1p)" 
label variable postfeedbackxT4 "Post-feedback $\times$ T4 (3n/0p)" 
label variable postexperiment "Post-experiment" 
label variable postexperimentxT2 "Post-experiment $\times$ T2 (1n/0p)" 
label variable postexperimentxT3 "Post-experiment $\times$ T3 (1n/1p)" 
label variable postexperimentxT4 "Post-experiment $\times$ T4 (3n/0p)" 

***********************************************************************************
***  [Table G10: Targeted Peer-Comparison Feedback Effects on Driving Performance
***********************************************************************************
**   [Table G10 - Panel A: Fuel Economy - VDL + INTOURO]
***********************************************************************************

** Period till 30-04-2016:
esttab msfueleconomyLpKM1 msfueleconomyLpKM2 msfueleconomyLpKM3 msfueleconomyLpKM4 using "$paperpath/TABFuelPeerCompShortPeriod.tex", replace f ///
keep(`verklvartwo') ///
label booktabs b(3) p(3) eqlabels(none) collabels(none) mlabels(none) ///
starlevels($^{*}$ 0.10 $^{**}$ 0.05 $^{***}$ 0.01) ///
cells(b(star  fmt(%9.3f) ) se(par fmt(%9.3f))) ///
stats(r2 N controls driverfe dayfe busdayfe, fmt(%9.3g) labels("R$^2$" "Number of trip-level observations" "Controls" "Driver fixed effects" "Day fixed effects" "Bus type $\times$ day fixed effects")) ///
varlabels(_cons Constant) ///
prehead("\tabcolsep=0.25cm" "\begin{tabular}{l*{@M}{C{2.0cm}}}\hline\hline" "Dependent variable: &\multicolumn{4}{c}{\textbf{Fuel Economy}}\\" "\cline{2-5}") posthead(\hline) ///
prefoot(\hline) postfoot("\hline" "\end{tabular}")


*****************************************************************************
**    [Table G10 - Panel B: Acceleration, Braking and Cornering - VDL + INTOURO]
*****************************************************************************
** Period till 30-04-2016:
esttab msacceleratie1 msrem1 msbochten1 using "$paperpath/TABABCPeerCompShortPeriod.tex", replace f ///
keep(`verklvartwo') ///
label booktabs b(3) p(3) eqlabels(none) collabels(none) mlabels(none) ///
starlevels($^{*}$ 0.10 $^{**}$ 0.05 $^{***}$ 0.01) ///
cells(b(star  fmt(%9.3f) ) se(par fmt(%9.3f))) ///
stats(r2 N controls driverfe dayfe busdayfe, fmt(%9.3g) labels("R$^2$" "Number of trip-level observations" "Controls" "Driver fixed effects" "Day fixed effects" "Bus type $\times$ day fixed effects")) ///
varlabels(_cons Constant) ///
prehead("\tabcolsep=0.25cm" "\begin{tabular}{l*{@M}{C{2.0cm}}}\hline\hline" "Dependent variable: &\multicolumn{1}{c}{\textbf{Acceleration}}&\multicolumn{1}{c}{\textbf{Braking}}&\multicolumn{1}{c}{\textbf{Cornering}} \\" "\cline{2-4}") posthead(\hline) ///
prefoot(\hline) postfoot("\hline" "\end{tabular}")



******************************************************************************
** [Tables G8 + G9 -- Difference in differences (DID) effects]
******************************************************************************
* Clustering by date instead of chauf_nr_rug. This leads to the most conservative (i.e. largest) standard errors - it does not make much of a difference though. 

******************************************************************************
*** [Table G8 -- Effect of Announcement EcoManager Campaign on Fuel Economy]
******************************************************************************
** DID effect announcement (*0)
gen byte tijd = 0
replace tijd = datum>=date("09-11-2015", "DMY") & !missing(datum)
gen byte treated = 0 
replace treated = 1 if regio == "FR"
reg dep_fueleconomyLpKM tijd##treated if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") ,  vce(cl datum)
** = same outcome as: 
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , t(treated) p(tijd) cl(datum)
*Diff-in-Diff	-0.112	0.107	1.05	0.295

** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
reg dep_fueleconomyLpKM b1.tijd##treated if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") ,  vce(cl datum)
reg dep_fueleconomyLpKM tijd##b1.treated if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") ,  vce(cl datum)
reg dep_fueleconomyLpKM b1.tijd##b1.treated if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") ,  vce(cl datum)

**** Alternative results *** NOT REPORTED IN PAPER ****
* a) Without clustering
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , t(treated) p(tijd) 
*Diff-in-Diff	-0.112	0.042	2.64	0.008***
* b) When clustering at driver (chauf_nr_rug)
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , t(treated) p(tijd) cl(chauf_nr_rug)
*Diff-in-Diff	-0.112	0.075	1.50	0.135

* + covariates
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , t(treated) p(tijd) cl(datum) cov($covBusType $covPassengers $covEnvironm $covPostCoaching)
* Diff-in-Diff	-0.100	0.105	0.95	0.342

** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
* reg dep_fueleconomyLpKM b1.tijd##treated $covBusType $covPassengers $covEnvironm $covPostCoaching  if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , vce(cl datum)
* reg dep_fueleconomyLpKM tijd##b1.treated $covBusType $covPassengers $covEnvironm $covPostCoaching  if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , vce(cl datum)
* reg dep_fueleconomyLpKM b1.tijd##b1.treated $covBusType $covPassengers $covEnvironm $covPostCoaching  if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") , vce(cl datum)

******************************************************************************
*** [Table G9 -- Effect of Introduction General Feedback on Fuel Economy]
******************************************************************************
** DID effect feedback
gen byte tijd2 = 0
replace tijd2 = datum>=date("15-12-2015", "DMY") & !missing(datum)

****************************************************************************************************
* After April 30, 2016, coaching records are incomplete in FR, so take period till 30-04-2016
****************************************************************************************************
* Baseline: 01-07-2015 - 08-11-2015: Treatment: 09-11-2015 - 30-04-2016 (*2)
reg dep_fueleconomyLpKM tijd2##treated if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY"),  vce(cl datum)  
*  _cons	27.70798	.0671263	412.77	0.000	27.57589	27.84007
** = same outcome as: 
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , t(treated) p(tijd2) cl(datum)
** tijd2#treated	
* 1	1	-.0723099	.0762872	-0.95	0.344	-.2224276	.0778078

** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , t(tijd2) p(treated) cl(datum)
** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
reg dep_fueleconomyLpKM b1.tijd2##treated   if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , vce(cl datum)
*       _cons	27.28017	.0611545	446.09	0.000	27.15983	27.4005
reg dep_fueleconomyLpKM tijd2##b1.treated    if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , vce(cl datum)
* 		_cons |   24.16128   .0627455   385.07   0.000      24.0378    24.28475
reg dep_fueleconomyLpKM b1.tijd2##b1.treated  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , vce(cl datum)
*  _cons |   23.66116   .0466009   507.74   0.000     23.56946    23.75286	


* + covariates (matters here because of coaching program  in FR region in treatment period)
reg dep_fueleconomyLpKM tijd2##treated  postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY"),  vce(cl datum)  
*    _cons	25.1924	.0964822	261.11	0.000	25.00254	25.38225
** = same outcome as: 
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , t(treated) p(tijd2) cl(datum) cov(postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching)
*tijd2#treated	
*	Diff-in-Diff	-0.022	0.078	0.28	0.779

** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , t(tijd2) p(treated) cl(datum) cov(postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching)
** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
reg dep_fueleconomyLpKM b1.tijd2##treated  postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching   if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , vce(cl datum)
*     _cons |    24.5478   .0570648   430.17   0.000     24.43551    24.66009
reg dep_fueleconomyLpKM tijd2##b1.treated  postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching   if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , vce(cl datum)
*             _cons |   23.74256   .1025737   231.47   0.000     23.54071     23.9444
reg dep_fueleconomyLpKM b1.tijd2##b1.treated postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") , vce(cl datum)
*       _cons |     23.076   .0823523   280.21   0.000     22.91395    23.23805

******************************************************************************
*** [END Table G9 -- Effect of Introduction General Feedback on Fuel Economy]
******************************************************************************

******************************************************************************************************************************************************
*** [Table XX -- Combined Effect of Announcement EcoManager Campaign and Introduction General Feedback]
******************************************************************************************************************************************************
****************************************************************************************************
* After April 30, 2016, coaching records are incomplete in FR, so take period till 30-04-2016
****************************************************************************************************
* Baseline: 01-07-2015 - 08-11-2015: Treatment: 09-11-2015 - 30-04-2016, exclude period after announcement but before introduction: 09-11-2015 to 15-12-2015 (*3)
reg dep_fueleconomyLpKM tijd##treated if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")),  vce(cl datum)  
*   _cons |   27.67665   .0803732   344.35   0.000      27.5184    27.83489
** = same outcome as: 
diff dep_fueleconomyLpKM  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , t(treated) p(tijd) cl(datum)
** tijd#treated	
*  1 1  |  -.0968725   .0831215    -1.17   0.245    -.2605266    .0667817

** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , t(tijd) p(treated) cl(datum)
** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
reg dep_fueleconomyLpKM b1.tijd##treated   if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")), vce(cl datum)
*        _cons |   27.28017    .061168   445.99   0.000     27.15974     27.4006
reg dep_fueleconomyLpKM tijd##b1.treated  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , vce(cl datum)
* 		_cons |   24.15451   .0758795   318.33   0.000     24.00511     24.3039
reg dep_fueleconomyLpKM b1.tijd##b1.treated  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , vce(cl datum)
*   _cons |   23.66116   .0466112   507.63   0.000     23.56939    23.75293


* + covariates (matters here because of coaching program  in FR region in treatment period)
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , t(treated) p(tijd) cl(datum) cov(postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching)
*tijd#treated	
*	Diff-in-Diff	0.001	0.081	0.02	0.986

** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , t(tijd) p(treated) cl(datum) cov(postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching)
** Just to get remaining s.e.'s table (different benchmark to generate relevant _cons + corresponding s.e)
reg dep_fueleconomyLpKM b1.tijd##treated  postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching   if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , vce(cl datum)
*       _cons |   24.54331   .0588938   416.74   0.000     24.42736    24.65927
reg dep_fueleconomyLpKM tijd##b1.treated  postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching  if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")), vce(cl datum)
*       _cons |   23.77713   .1146099   207.46   0.000     23.55148    24.00278
reg dep_fueleconomyLpKM b1.tijd##b1.treated postfeedbackxT* T2 T3 T4  noreport nonotification $covBusType $covPassengers $covEnvironm $covPostCoaching if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (datum<date("09-11-2015", "DMY") | datum>=date("15-12-2015", "DMY")) , vce(cl datum)
*       _cons |   23.05176   .0824277   279.66   0.000     22.88947    23.21404


************************************************************************************
* Footnote G6: Limit attention to drivers in Treatment Region who are never coached
************************************************************************************
** Announcement effect/without controls
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<date("15-12-2015", "DMY") & (regio=="ZH" | coachdatum_1==.), t(treated) p(tijd) cl(datum)
* Diff-in-Diff	-0.036	0.114	0.31	0.754

** Feedback effect/without controls
diff dep_fueleconomyLpKM if datum>=date("01-07-2015", "DMY") & datum<=date("30-04-2016", "DMY") & (regio=="ZH" | coachdatum_1==.) , t(treated) p(tijd2) cl(datum)
* Diff-in-Diff    | -0.113  | 0.079   | 1.43    | 0.154


graph close
log close

